#!/usr/bin/env bash


proxyUrl=http://192.168.1.113:10808
## 安装docker

#安装yum-config-manager工具
if ! yum list installed |grep -q yum-utils;then
    yum -y install yum-utils
fi

#设置yum源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

#安装docker-ce版本
#if ! yum list installed |grep -q 20.10.21;then
yum remove -y docker* containerd
yum install -y docker-ce
#fi
#启动并设置开机自启
rm -f /etc/docker/daemon.json
cat >/etc/docker/daemon.json<<EOF
{
    "proxies": {
      "http-proxy": "192.168.1.113:10808",
      "https-proxy": "192.168.1.113:10808"
    },
    "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
#if ! grep -q HTTP_PROXY /lib/systemd/system/docker.service;then
#sed -i '/\[Service\]/a\
#Environment="HTTP_PROXY=192.168.1.113:10808"\
#Environment="HTTPS_PROXY=192.168.1.113:10808"' /lib/systemd/system/docker.service
#fi

systemctl enable --now docker
systemctl restart docker
systemctl status docker containerd
